﻿using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

namespace Codeplex.STSDTS.Entities
{
    [XmlRoot("Farm")]
    public class Farm
    {

        [XmlArray("Solutions")]
        public List<Solution> Solutions
        {
            get; set;
        }

        /// <summary>
        /// Deserialize the given farm file
        /// </summary>
        /// <param name="farmFile">XML file representing the farm</param>
        /// <returns></returns>
        public static Farm Deserialize(string farmFile)
        {
            Farm farm;
            var farmFileInfo = new FileInfo(farmFile);
            using (var stream = farmFileInfo.OpenRead())
            {
                var serializer = new XmlSerializer(typeof(Farm));
                farm = (Farm)serializer.Deserialize(stream);
            }
            return farm;
        }

    }
}
